package com.bainc.web.server;

import com.bainc.web.client.ProfileService;
import com.bainc.web.shared.LoginInfo;
import com.bainc.web.shared.UserProfile;
import com.bainc.web.shared.types.Address;
import com.bainc.web.shared.types.ContactInfo;
import com.bainc.web.shared.types.Name;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

/*
 * Provides methods to manage profile of a user from UI.
 */
public class ProfileServiceImpl extends RemoteServiceServlet implements ProfileService {

	@Override
	public UserProfile fetch(LoginInfo info) {
		UserProfile profile = new UserProfile();
		profile.setLoginId(info.getLoginId());
		
		Name name = new Name("Sachin");
		name.setMiddle("Ramesh");
		name.setLast("Tendulkar");
		profile.setName(name);
		
		ContactInfo contactInfo = new ContactInfo("sachintendulkar@gmail.com");
		contactInfo.setSecondaryEmailId("srtendulkar@yahoo.com");
		contactInfo.setPhoneNumber(4085567788L);
		
		Address address = new Address();
		address.setFirstLine("1232 Inline Drive");
		address.setSecondLine("Apartment 420");
		address.setCity("New York City");
		address.setState("New York");
		contactInfo.setAddress(address);
		
		profile.setContactInfo(contactInfo);
		
		return profile;
	}
}